package com.situ.sal.service.impl;
import java.util.List;

import com.situ.login.entity.SysUser;
import com.situ.util.entity.CstCustomer;
import com.situ.util.entity.CstLinkman;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;


import com.situ.sal.service.SalChanceService;
import com.situ.sal.dao.SalChanceDao;
import com.situ.sal.entity.SalChance;
/**
 * SalChance的服务接口的实现类
 * 
 * @author 胡文 qq:986776
 *
 */
@Service
public class SalChanceServiceImpl implements SalChanceService {
	private final Logger LOG = LogManager.getLogger(this.getClass());

	@Autowired
	private SalChanceDao salChanceDao;

	/**
	 * 查询....
	 */
	@Override
	public List<SalChance> find(SalChance value) {

		List<SalChance> result = salChanceDao.selectSalChanceByObj(value);

		return result;
	}

	/**
	 * 根据id查询
	 */
	@Override
	public SalChance findOne(Integer id) {

		SalChance result = salChanceDao.selectSalChanceById(id);

		return result;
	}

	/**
	 * 添加不为空
	 */
	@Override
	public SalChance saveNotNull(SalChance value) {
		if (value == null) {
			if (LOG.isDebugEnabled()) {
				LOG.debug("执行将SalChance中属性值不为null的数据保存到数据库-->失败:对象不能为空");
			}
			return value;
		}
		if (value.getChc_cust_name() == null || value.getChc_title() == null || value.getChc_rate() == null || value.getChc_desc() == null || value.getChc_create_date() == null || value.getChc_status() == null) {
			if (LOG.isDebugEnabled()) {
				LOG.debug("执行将SalChance中属性值不为null的数据保存到数据库-->失败:存在不能为空的空值");
			}
			return value;
		}
		int result = salChanceDao.insertNotNullSalChance(value);
		if (LOG.isDebugEnabled()) {
			LOG.debug("执行将SalChance中属性值不为null的数据保存到数据库-->结果:", result);
		}
		return value;
	}

	@Override
	/**
	 * 修改不为空
	 */
	public int updateNotNullById(SalChance value) {
		if (value == null) {
			if (LOG.isDebugEnabled()) {
				LOG.debug("执行通过SalChance的id更新SalChance中属性不为null的数据-->失败:对象为null");
			}
			return 0;
		}
		int result = salChanceDao.updateNotNullSalChanceById(value);
		if (LOG.isDebugEnabled()) {
			LOG.debug("执行通过SalChance的id更新SalChance中属性不为null的数据-->结果:", result);
		}
		return result;
	}

	/**
	 * 删除
	 */
	@Override
	public int deleteById(Integer id) {
		if (id == null) {
			if (LOG.isDebugEnabled()) {
				LOG.debug("执行通过SalChance的id删除SalChance-->失败:id不能为空");
			}
			return 0;
		}
		int result = salChanceDao.deleteSalChanceById(id);
		if (LOG.isDebugEnabled()) {
			LOG.debug("执行通过SalChance的id删除SalChance-->结果:", result);
		}
		return result;
	}

	@Override
	public List<SalChance> queryByLike(SalChance sc) {
		return salChanceDao.queryByLike(sc);
	}

	@Override
	public List<SalChance> queryByLike2(SalChance sc) {
		return salChanceDao.queryByLike2(sc);
	}

	@Override
	public void deleteSalChanceById(int id) {
		salChanceDao.deleteSalChanceById(id);
	}

	@Override
	public void delSalPlanById(int id) {
		salChanceDao.delSalPlanById(id);
	}

	@Override
	public void addSalChance(SalChance sc) {
		salChanceDao.addSalChance(sc);
	}

	@Override
	public void updateSalChance(SalChance sc) {
		salChanceDao.updateSalChanceById2(sc);
	}

	@Override
	public SalChance selectSalChanceById(int id) {
		return salChanceDao.selectSalChanceById(id);
	}

	@Override
	public SysUser queryusersById(int id) {
		return salChanceDao.queryusersById(id);
	}

	@Override
	public List<SysUser> queryusers() {
		return salChanceDao.queryusers();
	}

    @Override
    public void updateSalChanceById1(SalChance s) {
        salChanceDao.updateSalChanceById1(s);
    }

	@Override
	public int getCount(int id) {
		return salChanceDao.getCount(id);
	}
}